/**
 * article模块接口列表
 */

import base from '../base' // 导入接口域名列表
import axios from '@/common/utils/http' // 导入http中创建的axios实例
import qs from 'qs' // 根据需求是否导入qs模块

const account = {
  // 验证码
  /**
   * @param {Object} params - {receiver, recaptcha_response}
   * */
  verificationCreate (params) {
    return axios.post(`${base.gene}/account/verifications/`, qs.stringify(params))
  },
  /**
   * @param {int} id - id
   * @param {Object} params
   * */
  verificationDetail (id, params) {
    return axios.get(`${base.gene}/account/verifications/${id}/`, {
      params: params
    })
  },
  // 用户注册
  /**
   * @param {Object} params - {verification_id, username, password, source_type, source_id}
   * */
  userCreate (params) {
    return axios.post(`${base.gene}/account/users/`, qs.stringify(params))
  },
  // 邮寄地址
  addressList (params) {
    return axios.get(`${base.gene}/account/addresses/`, {
      params: params
    })
  },
  /**
   * @param {Object} params - {receiver_name, receiver_phone, area, detail_address, zip_code, default_address}
   * */
  addressCreate (params) {
    return axios.post(`${base.gene}/account/addresses/`, qs.stringify(params))
  },
  /**
   * @param {int} (id, params) - id
   * @param {Object} params
   * */
  addressDetail (id, params) {
    return axios.get(`${base.gene}/account/addresses/${id}/`, {
      params: params
    })
  },
  addressPatch (id, params) {
    return axios.patch(`${base.gene}/account/addresses/${id}/`, params)
  },
  addressDelete (id, params) {
    return axios.delete(`${base.gene}/account/addresses/${id}/`, {
      params: params
    })
  },
  // 地区列表信息
  areaList (params) {
    return axios.get(`${base.gene}/account/areas/`, {
      params: params
    })
  },
  areaCreate (params) {
    return axios.post(`${base.gene}/account/areas/`, params)
  },
  // 获得area信息
  areaDetail (id, params) {
    return axios.get(`${base.gene}/account/areas/${id}/`, {
      params: params
    })
  }
}

export default account
